/*
 * BibliotecaInitialChoice.java
 *
 * Created on 29 settembre 2008, 12.22
 */

package it.biblioteca;

import it.biblioteca.util.BookList;
import it.biblioteca.util.ComboFields;
import it.biblioteca.util.UtilFileOperation;
import javax.swing.ImageIcon;

/**
 *
 * @author  giovine
 */
public class BibliotecaInitialChoice extends javax.swing.JFrame {
    
    BookList my_list;
    ComboFields my_fields;
    
    /** Creates new form BibliotecaInitialChoice */
    public BibliotecaInitialChoice(BookList b, ComboFields c) {
        this.my_list = b;
        this.my_fields = c;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        add_books_bt = new javax.swing.JButton();
        manage_books_bt = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("BiblioTeCa");
        setIconImage(new ImageIcon("files/icon_desktop.png").getImage());
        setResizable(false);
        setUndecorated(true);

        add_books_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/biblioteca/icons/icon_new_book.png"))); // NOI18N
        add_books_bt.setText("Aggiungi nuovi libri");
        add_books_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                add_books_btActionPerformed(evt);
            }
        });

        manage_books_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/biblioteca/icons/icon_manage_books.png"))); // NOI18N
        manage_books_bt.setText("Gestisci la biblioteca");
        manage_books_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                manage_books_btActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Purisa", 1, 18));
        jLabel1.setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/biblioteca/images/Header.png"))); // NOI18N

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/it/biblioteca/icons/icon_close.png"))); // NOI18N
        jButton1.setText("Chiudi");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(add_books_bt)
                        .addGap(28, 28, 28)
                        .addComponent(manage_books_bt))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(161, 161, 161)
                        .addComponent(jButton1)))
                .addContainerGap(26, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(add_books_bt)
                    .addComponent(manage_books_bt))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void add_books_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_add_books_btActionPerformed
    //Start new form to insert book
    BibliotecaAddBooksFrame add_books = new BibliotecaAddBooksFrame(this.my_list,this.my_fields);
    add_books.setLocationRelativeTo(null);
    add_books.setVisible(true);
    dispose();
}//GEN-LAST:event_add_books_btActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    UtilFileOperation.saveDataBase(this.my_list);
    System.exit(0);
}//GEN-LAST:event_jButton1ActionPerformed

private void manage_books_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manage_books_btActionPerformed
    BibliotecaManagementFrame  manage_books = new BibliotecaManagementFrame(this.my_list,this.my_fields);
    manage_books.setLocationRelativeTo(null);
    manage_books.setVisible(true);
    dispose();
}//GEN-LAST:event_manage_books_btActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton add_books_bt;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton manage_books_bt;
    // End of variables declaration//GEN-END:variables

}
